using UnityEngine;

public class IS_CoinCreator_Script : MonoBehaviour
{
    [Header("金币预设体")] 
    public GameObject coinPrefab;
    
    private float timer = 0;

    private void Update()
    {
        timer += Time.deltaTime;
        if (timer > 1)
        {
            // 在随机位置生成金币
            float x = Random.Range(-10, 10);
            float z = Random.Range(0, 10);
            GameObject coin = Instantiate(coinPrefab, new Vector3(x, 10, z), Quaternion.identity);
            // 定时2s销毁金币
            Destroy(coin, 2);
            // 计时器归0
            timer = 0;
        }
    }
}